#include "longestCommonSubsequence.h"
int longestCommonSubsequence(string text1, string text2) {
  int size_1 = text1.length()+1;
  int size_2 = text2.length()+1;
  vector<vector<int>> DP(size_1, vector<int>(size_2, 0));
  for (int i = 0; i < size_1; i++) {
    for (int j = 0; j < size_2; j++) {
      if (i == 0 || j == 0) {
        DP[i][j] = 0;
      } else if (text1.at(i-1) == text2.at(j-1)) {
        DP[i][j] = DP[i - 1][j - 1] + 1;
      } else
        DP[i][j] = std::max(DP[i - 1][j], DP[i][j - 1]);
    }
  }
  return DP[size_1 - 1][size_2 - 1];
}